home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Graphics / FlashMandel / Sources / Modules / JuliaPPC.P < prev    next >
Encoding:
Text File  |  2001-05-20  |  2.8 KB  |  81 lines

  1. ********************************************************************************************************
  2. **            Written by Dino Papararo            7-March-2001
  3. **
  4. **  FUNCTION
  5. **
  6. **    JuliaPPC -- perform Z = Z^2 + C iteration.
  7. **
  8. **  SYNOPSIS
  9. **
  10. **    ULONG JuliaPPC (ULONG Iterations,long double Cre,long double Cim,long double JKre,long double JKim)
  11. **
  12. **
  13. **  This function tests if a point belongs or not at Julia set
  14. **
  15. **  Optimized for pipelines of PPC processors.
  16. **
  17. **  r3:Iterations
  18. **  f1:Cre/Zr f2:Cim/Zi f3:JKre f4:JKim f5:Tmp1/Zr2 f6:Tmp2/Zi2 f7:Dist f8:MaxDist
  19. ********************************************************************************************************
  20.  
  21.  
  22.                 include powerpc/ppcmacros.i
  23.                 include powerpc/powerpc.i
  24.  
  25.                 xref _PowerPCBase
  26.  
  27.                 xdef _JuliaPPC
  28.  
  29.                 section code
  30.  
  31.                 cpu POWERPC
  32.  
  33. _JuliaPPC
  34.  
  35.                  prolog             ; start
  36.  
  37.                  lf     f8,Radius   ; MaxDist = Radius
  38.  
  39.                  mtctr  r3          ; Load Iterations into counter
  40.  
  41. **************************************************************************
  42. * Dino Papararo Julia PPC ASM function fastest I have ever seen and
  43. * without any pipeline wait state for the maximu speeeeed possible on PPC.
  44. * Based on the HAAGE&PARTNER MandelBrot code.
  45. **************************************************************************
  46. *
  47. *                 fsub   f8,f8,f3    ; MaxDist = Radius - JKre
  48. *.Loop
  49. *                 fmsub  f6,f2,f2,f3 ; Tmp2 = Zi^2 - JKre
  50. *                 fadd   f5,f1,f1    ; Tmp1 = 2 * Zr
  51. *                 fmadd  f7,f1,f1,f6 ; Dist = Zr^2 + Tmp2
  52. *                 fmsub  f1,f1,f1,f6 ; Zr = Zr^2 - Tmp2
  53. *                 fmadd  f2,f2,f5,f4 ; Zi = Tmp1 * Zi + JKim
  54. *                 fcmpu  f7,f8       ; if Dist > MaxDist and
  55. *                 bdnzf+ GT,.Loop    ; Iterations != 0 goto Loop
  56. *************************************************************************
  57. * Dino Papararo Julia PPC ASM function for rendering Mandelbrot set a
  58. * bit slower than HAAGE&PARTNER based one but simplest, more elegant and
  59. * without any pipeline wait state too ;-)
  60. *
  61. .Loop
  62.  
  63.                  fmul   f6,f2,f2    ; zi2 = zi * zi
  64.                  fadd   f2,f2,f2    ; zi = zi + zi
  65.                  fmadd  f7,f1,f1,f6 ; dist = zr * zr + zi2
  66.                  fmsub  f5,f1,f1,f6 ; zr = zr * zr - zi2
  67.                  fmadd  f2,f1,f2,f4 ; zi = zr * zi + JKim
  68.                  fadd   f1,f5,f3    ; zr += JKre
  69.                  fcmpu  f7,f8       ; compare dist with radius
  70.                  bdnzf+ GT,.Loop    ; if maxdist > radius or --iterations != 0 goto Loop
  71. *************************************************************************
  72.  
  73. .End
  74.  
  75.                  mfctr  r3          ; Store Iterations from counter
  76.  
  77.                  epilog             ; end
  78.  
  79.                  section data
  80.  
  81. Radius           dc.d  4.0